#include "Spi.h"

void start_screen () {
  osd.setPanel(5,7);
  osd.openPanel();
  osd.printf_P(PSTR("\x88\x89\x8a\x8b|\x8c\x8d\x8e\x8f by bluuu v0.1 alfa|\xb0\xb1\xb2\xb3"));
  osd.closePanel();
}

void countdown_screen () {
  osd.setPanel(6,10);
  osd.openPanel();
  osd.printf_P(PSTR("Initializing ..."));
  osd.closePanel();
  for (char i = 9;  i>=0; i--)
  {
  osd.setPanel(23,10);
  osd.openPanel();
  osd.print(i+0);
  osd.closePanel();
  delay(1000);
  }
}

void detect_screen (void) {
  osd.setPanel(5,3);
  osd.openPanel();

  digitalWrite(MAX7456_SELECT,LOW);
  Spi.transfer(MAX7456_STAT_reg_read);//status register
  byte osdstat_r = Spi.transfer(0xff);

  if ((B00000001 & osdstat_r) == 1){ //PAL
    osd.printf_P(PSTR("System mode: PAL"));
  }
  else if((B00000010 & osdstat_r) == 1){ //NTSC
    osd.printf_P(PSTR("System mode: NTSC"));
  }
  else{
      if (EEPROM.read(PAL_NTSC_ADDR) == 0){ //NTSC
    osd.printf_P(PSTR("System mode: NTSC"));
      } 
      else { //PAL
    osd.printf_P(PSTR("System mode: PAL"));
      }
      digitalWrite(MAX7456_SELECT,LOW);
  }  
  osd.closePanel();
}
